<template>
     <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getOrders"
    >
        <van-panel  v-for="(goods, index) in orderList" v-bind:key="index" :title="'订单：' + goods.orderSn" style="margin-top: 10px;">
            <router-link :to="`/goods/detail/${goods.goodsId}`">
                <van-card
                    :key="goods.goodsId"
                    :desc="goods.goodsSpecName"  
                    :title="goods.goodsTitle"
                    :thumb="`/images/${goods.goodsTitleImage}`"
                >
                 </van-card>
            </router-link>
            <div slot="footer" class="footer" style="text-align: right;">
                <van-button size="small" @click="$router.push(`/order/refundDetail/${goods.refundId}`)">查看</van-button>
            </div>
        </van-panel>
    </van-list>
</template>

<script>
export default {
    name: 'orderList',
    data() {
        return {
            pageNum: 0,
            pageSize: 10,
            total: -1,
            orderList: [],


            loading: false,
            finished: false,
        }
    },

    methods: { 
        getOrders() {
            if (this.total !== -1 && this.pageNum >= this.total) {
                this.finished = true;
                this.loading = false;
                return;
            }
            this.pageNum++;
            this.loading = true;
            this.$http.post('/shop/orderRefund/front/getOrderRefundList', {
                pageNum: this.pageNum,
                pageSize: this.pageSize
            }).then(res => {
                console.log('退换修订单列表获取成功')
                console.log(res)
                this.loading = false;
                if (res.status === 0) {
                    this.total = res.data.total;
                    this.orderList = this.orderList.concat(res.data.rows);
                    if (this.pageNum == this.total|| (this.pageNum == 1 && res.data.rows.length == 0)) {
                        this.finished = true;
                    }
                } else {
                    this.finished = true;
                    this.$toast.fail(res.message);
                }
            })
        },
    }
}
</script>

<style>

</style>
